package com.woniu.rabbit.publish_model.producer;

import com.woniu.rabbit.topic_model.excange_queue_conf.PublishExchangeAndQueueConfig;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/fanout")
@Api(tags = "广播模型")
public class FanoutProducerController {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    @RequestMapping("/producer")
    @ApiOperation("发布订阅模式生产者")
    public ResponseEntity fanoutProducer(String msg) {
        rabbitTemplate.convertAndSend(PublishExchangeAndQueueConfig.EXCHANGE_NAME, msg);
        return ResponseEntity.ok("消息发送成功：" + msg);
    }
}
